INCLUDE_DIRECTORIES(${ROSS_SOURCE_DIR} ${ROSS_BINARY_DIR})

SET(srw_srcs
    srw.c
    srw.h
)

IF(WITH_NETDMF)
	# Must Have NetDMF
	FIND_PACKAGE(NetDMF NO_MODULE REQUIRED)
	IF(NetDMF_FOUND)
		INCLUDE_DIRECTORIES(${NETDMF_INCLUDE_DIRS})

		LINK_DIRECTORIES(${NETDMF_LIBRARY_DIRS})
		LINK_DIRECTORIES(${NETDMF_LIBRARY_DIRS}/paraview-3.8)

	ENDIF(NetDMF_FOUND)

	SET(srw_srcs ${srw_srcs} rn-netdmf.c rn-netdmf-wrapper.cpp)

        ADD_DEFINITIONS(-DWITH_NETDMF)

	FIND_PACKAGE(LibXml2 REQUIRED)
	FIND_PACKAGE(HDF5)
	FIND_PACKAGE(XDMF NO_MODULE REQUIRED)

	INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIR})
	INCLUDE_DIRECTORIES(${XDMF_INCLUDE_DIRS})
	INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})

	LINK_DIRECTORIES(${XDMF_LIBRARY_DIRS})
	LINK_DIRECTORIES(${HDF5_LIBRARY_DIRS})
	SET(SRW_LIBS ${SRW_LIBS} Xdmf NetDMF ${LIBXML2_LIBRARIES})

ENDIF(WITH_NETDMF)

ADD_EXECUTABLE(srw ${srw_srcs})

TARGET_LINK_LIBRARIES(srw ROSS m ${SRW_LIBS})

ADD_TEST(srwtest mpirun -np 1 ${CMAKE_CURRENT_BINARY_DIR}/srw --synch=1)
